import os
# -*- coding:utf-8 -*-
#from pymongo import MongoClient
from pymongo import MongoClient
import sys
reload(sys)
city = sys.argv[1]
mongo=MongoClient("mongodb://zhuge:7UgfAWbUtTKeMVGrSLwsHjB9xGjumnck@dds-2ze2f6d07e237dd42.mongodb.rds.aliyuncs.com:3717,dds-2ze2f6d07e237dd41.mongodb.rds.aliyuncs.com:3717/admin?replicaSet=mgset-1100081&socketTimeoutMS=10000")
if city in 'bj':
    dbname = 'spider'
else:
    dbname = 'spider_'+str(city)
col = mongo.get_database(dbname).etl_borough
with open('borough_etl_'+city, 'r') as f:
    for i,line in enumerate(f.readlines()):
        line = line.strip('\n')
        print line
        if col.find_one({"borough_name":line}) == None:
            col.insert({'borough_name':line})
